﻿using UnityEngine;

namespace Core
{
    public class LayerMaskHelper
    {
        public static int GetLayerMask(string layerMask)
        {
            if (string.IsNullOrEmpty(layerMask))
                return 0;

            int result = 0;
            foreach(var str in layerMask.Split('#'))
            {
                if(int.TryParse(str, out var layer))
                {
                    var name = LayerMask.LayerToName(layer);
                    result |= 1 << LayerMask.GetMask(name);
                }
            }
            return result;
        }
    }
}